'''
Created on Oct 15, 2014

@author: azhelezny
'''
def fibCycle(n, k):
    preprevoius = 1
    prevoius = 1
    current = 1
    counter = 1;
    while(counter<=n-2):
        current = prevoius + k*preprevoius
        preprevoius = prevoius
        prevoius = current
        #print('iteration '+format(counter)+' : '+format(current)+' F-2:'+format(preprevoius)+' F-1:'+format(prevoius))
        counter +=1 
    return current


print(format(fibCycle(34, 5)))   